package com.mdp.workflow.re.service;

import com.mdp.workflow.re.entity.ProcdefNodeInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.concurrent.TimeUnit;
 

@Service
public class ProcdefNodeInfoCacheService {
	
	@Autowired 
	RedisTemplate redisTemplate;
	
	
	String cachKey="wf_re_procdef_node_info_";
	
	public void putNodeInfos(String procDefId,String branchId,List<ProcdefNodeInfo> nodeInfos) {
		redisTemplate.opsForHash().put(cachKey+procDefId, branchId, nodeInfos);
		redisTemplate.expire(cachKey+procDefId, 100, TimeUnit.DAYS);
	}
	
	public List<ProcdefNodeInfo>   getNodeInfos(String procDefId, String branchId) {
		return (List<ProcdefNodeInfo>) redisTemplate.opsForHash().get(cachKey+procDefId, branchId);
	}

	
}
